#region Summary

// 
// Owner : JackieHan 
// 
// Solution : LearnSolution 
// 
// Project : JackieHan.NHibernate3.Configuration
// 
// File : NHibernateHelper.cs
// 
// CopyRight : Copyright © 2010-2011 Skomart Corporation, All Rights Reserved 
// 
// Summary : NHibernate Helper类
// 
// History : 
//			2010-09-14 11:41:36	    Create 
// 

#endregion

#region Using

using System;
using System.Collections.Generic;
using NHibernate;

#endregion

namespace JackieHan.NHibernate3.Configuration
{
    /// <summary> 
    /// NHibernate Helper类
    /// </summary>
    public class NHibernateHelper
    {
        private static ISessionFactory sessionFactory;
        private static object lockObj = new object();

        private NHibernateHelper()
        {
            
        }

        /// <summary>
        /// 获取单例SessionFactory
        /// </summary>
        public static ISessionFactory SessionFactory
        {
            get
            {
                if (sessionFactory == null)
                {
                    lock (lockObj)
                    {
                        if (sessionFactory == null)
                        {
                            InitializeSessionFactory();
                        }
                    }
                }
                return sessionFactory;
            }
        }

        private static void InitializeSessionFactory()
        {
            NHibernate.Cfg.Configuration cfg = LambdaConfiguration.CompletedConfig();
            sessionFactory = cfg.BuildSessionFactory();
        }
    }
}